set more 1

use bgt_employer_firm_07_to_14.dta, clear

keep if inlist(year, 2007, 2010, 2012)

gen educ=edu
replace educ=maxedu if educ==.

gen edureq=(educ!=.)
	
	gen eduhs=(educ==12 & !missing(educ))
	gen edusc=((educ==13 | educ==14) &!missing(educ))
	gen edubd=(educ==16  &!missing(educ))
	gen eduma=(educ==18 &!missing(educ))
	gen eduphd=(educ==21 &!missing(educ))

gen edubdgd=.
replace edubdgd=1 if (edubd==1 | eduma==1 | eduphd==1)
replace edubdgd=0 if (edubd==0 & eduma==0 & eduphd==0)


gen exper=exp
replace exper=maxexp if exp==.

drop edu maxedu exp maxexp

gen expreq=exper!=.
	
	gen exp_0to1=(exper>0 & exper<1 & !missing(exper))
	gen exp_1to2=(exper>=1 & exper<2 &  !missing(exper))
	gen exp_2to3=(exper>=2 & exper<3 & !missing(exper))
	gen exp_3to4=(exper>=3 & exper<4 & !missing(exper))
	gen exp_4to5=(exper>=4 & exper<5 & !missing(exper))
	gen exp_5to7=(exper>=5 & exper<7 & !missing(exper))
	gen exp_7to15=(exper>=7 & exper<15 & !missing(exper))


gen exp2=.
replace exp2=1 if (exp_2to3==1 | exp_3to4==1 | exp_4to5==1 | exp_5to7==1 | exp_7to15==1)
replace exp2=0 if (exp_2to3==0 & exp_3to4==0 & exp_4to5==0 & exp_5to7==0 & exp_7to15==0)

gen exp4=.
replace exp4=1 if (exp_4to5==1 | exp_5to7==1 | exp_7to15==1)
replace exp4=0 if (exp_4to5==0 & exp_5to7==0 & exp_7to15==0)
		

drop if fips=="na"

assert length(fips)==5

drop if inlist(statefip, 11, 72, 66)

drop if employerid==.
drop if jobid==.

egen empjobid =group(jobid employerid)
replace empjobid=. if employerid==.
replace empjobid=. if jobid==.
egen empjobstateid=group(employerid jobid statefip)

gen occsoc_broad=substr(occsoc,1,2)
gen occsoc_minor=substr(occsoc,1,3)
gen occsoc_detailed=occsoc

destring occsoc_broad, gen(occsoc_broad2)
destring occsoc_minor, gen(occsoc_minor2)
destring occsoc_detailed, gen(occsoc_detailed2)

tostring naics, replace
gen ind_major=substr(naics,1,2)

merge m:1 statefip year occsoc using data_for_jobtitle_vet13.dta.dta, keep(master match)


encode occsoc, g(outlier)
egen sdoccsoc=sd(outlier), by(empjobid)
drop if sdoccsoc>0

dann_vet_fj, replace


/*lvetvsoe*/
reg edubdgd lvetvsoe i.year i.state if dup_month_st<=50, cluster(statefip)
reghdfe edubdgd lvetvsoe  if dup_month_st<=50, a(year empjobid) vce(cluster statefip)
reghdfe edubdgd lvetvsoe  if dup_month_st<=50, a(year empjobstateid) vce(cluster statefip)

reg exp4 lvetvsoe i.year i.state  if dup_month_st<=50, cluster(statefip)
reghdfe exp4 lvetvsoe  if dup_month_st<=50, a(year empjobid) vce(cluster statefip)
reghdfe exp4 lvetvsoe  if dup_month_st<=50, a(year empjobstateid) vce(cluster statefip)

/*lvet_var*/
reg edubdgd lvet_var i.year i.state  if dup_month_st<=50, cluster(statefip)
reghdfe edubdgd lvet_var  if dup_month_st<=50, a(year empjobid) vce(cluster statefip)
reghdfe edubdgd lvet_var  if dup_month_st<=50, a(year empjobstateid) vce(cluster statefip)

reg exp4 lvet_var i.year i.state  if dup_month_st<=50, cluster(statefip)
reghdfe exp4 lvet_var  if dup_month_st<=50, a(year empjobid) vce(cluster statefip)
reghdfe exp4 lvet_var  if dup_month_st<=50, a(year empjobstateid) vce(cluster statefip)

/*lvet_var_bp*/
reg edubdgd lvet_var_bp i.year i.state  if dup_month_st<=50, cluster(statefip)
reghdfe edubdgd lvet_var_bp  if dup_month_st<=50, a(year empjobid) vce(cluster statefip)
reghdfe edubdgd lvet_var_bp  if dup_month_st<=50, a(year empjobstateid) vce(cluster statefip)

reg exp4 lvet_var_bp i.year i.state  if dup_month_st<=50, cluster(statefip)
reghdfe exp4 lvet_var_bp  if dup_month_st<=50, a(year empjobid) vce(cluster statefip)
reghdfe exp4 lvet_var_bp  if dup_month_st<=50, a(year empjobstateid) vce(cluster statefip)







